package com.youth.orderservice.mq.Config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class payOrderConfigMQ {

    //交换机队列名字
    public static final String Y_EXCHANGE = "Y";
    public static final String QUEUE_B = "QB";

    //交换机声明
    @Bean("yExchange")
    public DirectExchange yExchange(){
        return new DirectExchange(Y_EXCHANGE);
    }

    //延时队列声明
    @Bean("queueB")
    public Queue queueB(){
        return new Queue(QUEUE_B);
    }

    //将交换机和队列进行绑定
    @Bean
    public Binding queueABindingY(@Qualifier("queueB") Queue queueB,
                                  @Qualifier("yExchange") DirectExchange yExchange){
        return BindingBuilder.bind(queueB).to(yExchange).with("XB");
    }


}